function checkToken({
	HasTokenCb = null,
	pagePath = '',
	isTabBarPage = true
} = {}) {
	let token = uni.getStorageSync('token')
	if (token) {
		if (typeof HasTokenCb === 'function') {
			HasTokenCb()
		}
	} else {
		uni.switchTab({
			url: '/pages/user/user',
			success: () => {
				uni.setStorageSync('pagePath', pagePath)
				uni.setStorageSync('isTabBarPage', isTabBarPage)
				setTimeout(() => {
					uni.showToast({
						title: '请先登录',
						icon: "loading"
					})
				}, 200)
			}
		})
	}
}


function goBack() {
	let pagePath = uni.getStorageSync('pagePath')
	let isTabBarPage = uni.getStorageSync('isTabBarPage')

	if (pagePath) {
		if (isTabBarPage) {
			uni.switchTab({
				url: pagePath,
				success: () => {
					uni.removeStorageSync('pagePath')
					uni.removeStorageSync('isTabBarPage')
				}
			})
		} else {
			uni.redirectTo({
				url: pagePath,
				success: () => {
					uni.removeStorageSync('pagePath')
					uni.removeStorageSync('isTabBarPage')
				}
			})
		}
	}
}

export {
	checkToken,
	goBack
}
